package tree.递归;

import po.TreeNode;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 二叉搜索树的范围和938.java
 * @Description https://leetcode-cn.com/problems/range-sum-of-bst/
 * @createTime 2021年08月03日 19:14:00
 */
public class 二叉搜索树的范围和938 {
	private int var=0;
	public int rangeSumBST(TreeNode root, int low, int high) {
		if (root == null) {
			return 0;
		}
		rangeSumBST(root.left,low,high);
		if (root.val <= high && root.val >= low) {
			var=var+root.val;
		}
		rangeSumBST(root.right,low,high);
		return var;
	}
}
